package mywebapps.security.jsf;

import javax.annotation.PostConstruct;

import mywebapps.security.dao.RoleDao;
import mywebapps.security.model.Role;

public class DeleteRoleAction
{
    private RoleDao roleDao;
    private String roleId;
    private Role role;
    
    @PostConstruct
    public void init()
    {
        if (roleId != null) {
            role = roleDao.getRole(Integer.valueOf(roleId));
        }
    }
    
    public String delete()
    {
        if (roleId != null) {
            roleDao.deleteRole(role);
        }
        return "gotoViewRoles";
    }
    
    public String getRoleId()
    {
        return roleId;
    }

    public void setRoleId(String roleId)
    {
        this.roleId = roleId;
    }

    public RoleDao getRoleDao()
    {
        return roleDao;
    }

    public void setRoleDao(RoleDao roleDao)
    {
        this.roleDao = roleDao;
    }

    public Role getRole()
    {
        return role;
    }
}
